<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="description" content="" />
    <meta name="author" content="ChongMing" />
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="full-screen" content="yes">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-fullscreen" content="true">
    <meta name="360-fullscreen" content="true">
<title>体检</title>
</head>
<link href="../css/reset.min.css" rel="stylesheet" type="text/css" />
<link href="../css/examination/layout.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../css/ekang.css"/>
<script src="../js/jquery.min.js"></script>
<script src="../js/main.js"></script>
<script src="../js/ekang.js"></script>
<script src="../js/jquery.cookie.js"></script>
<script>
    $(function(){
        $('#I_name').val($.cookie('index_username'));
        $('#p_phone').html(getQueryString("user_phone"));
        $('#tx').css('background','url(' + getQueryString("user_img") + ') center center');
        $('#tx').css('backgroundSize','60px 60px');

        Main.get(textUrl+'user/getNewUserinfo',{uid:$.cookie("local_userId")},function(res){
            if(res.ret==0){
//                var img = res.data.avatar_file;
//                var name = res.data.user_name;
//                var phone = res.data.mobile;
//                $('#tx').css('background','url(' + img + ') center center');
//                $('#tx').css('backgroundSize','60px 60px');
//                $('#I_name').val(name);
//                $('#p_phone').text(phone);
                //成功执行
            }else if(res.ret==1){
                alert(res.msg);
            }
        })
        $('#individual_submit').click(function(){
           var val =  $('#I_name').val();
           var img_base = $('#blessingpic').val();
           if(val<1){
               alert('昵称不能为空')
           }else{
               $.ajax({
                   type : 'post',
                   url : textUrl+'user/updateInfo?',
                   data:{
                       uid:$.cookie("local_userId"),
                       nick_name:val,
                       avatar:img_base
                   },
                   dataType : 'json',
                   success : function(res) {
                       console.log(res);
                       if(res.ret==0){
                           prompt('修改成功')
                           setTimeout(function(){
                               location.href='http://www.ekangjiuyi.net/EKang2.0/index.html'
                           },1000)
                       }else{
                           alert(res.msg)
                       }
                   }
               });
           }
        });

        $('#back').click(function () {
            history.back();
        });
    })
    $(function(){
        var $container = $('.input-file');
        // 预览上传图片
        $container.on('change','input[name="photoFile"]',function(e){

            var $this = $(this),
                    file = null,
                    freader = null;
            for(var i=0;i<e.target.files.length;i++){

                file = e.target.files.item(i);

                //不是图片 跳出这一次循环
                if(!(/^image\/.*$/i.test(file.type)))
                {
                    continue;
                }

                //实例化FileReader API
                freader = new FileReader();

                freader.readAsDataURL(file);
                freader.onload = function(e){

                    //$('.paizhao').attr('src','' + e.target.result + '');
                    $('#tx').css('background','url(' + e.target.result + ') center center');
                    $('#tx').css('backgroundSize','60px 60px');
                    $('input[name="blessingpic"]').val(e.target.result);
                }
            }
        });
    });
</script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
<script src="../js/weixin2.js"></script>
<body>
<!--// 导航条-->
<div style="width: 100%;height: 45px;background-color: #38a16d;position: fixed;z-index: 10000">
    <h1 class="nav-title" style="font-size: 18px">修改个人资料</h1>
    <img src="../img/BackIcon.png" alt="返回" class="nav-backImg" id="back"/>
</div>
<br/><br/>
<div class="main">
    <div class="individual_center">
        <div class="head_portrait">
            <div class="left">头像</div>
            <div class="right">
                <div class="tx" id="tx"></div>
                <img class="jt" src="../img/icon_right.png">
            </div>
            <div class="input-file relative">
                <input class="absolute" type="file" id="photoFile" name="photoFile">
            </div>
            <input type="hidden" id="blessingpic" name="blessingpic">
        </div>
        <div class="name">
            <div class="left">昵称</div>
            <div class="right">
                <input id="I_name" value=""/>
                <img class="jt" src="../img/icon_right.png">
            </div>
        </div>
        <div class="phone">
            <div class="left">手机</div>
            <div class="right">
                <p id="p_phone"></p>
                <img class="jt" src="../img/icon_right.png">
            </div>
        </div>
    </div>
    <button id="individual_submit">提交</button>
</div>
</body>
</html>
